﻿<!doctype html>
<html>

<head>
    <link href="/stylesheets/base.css" rel="stylesheet">
    <link href="/stylesheets/style.css" rel="stylesheet">
    <script src="/js/baiduTemplate.js"></script>
</head>

<body>

    <article class="blogs">
        <h2 class="title_tj">
            <p>文章<span>推荐</span></p>
        </h2>
        <div class="newblog left">
          <% for(var i=0;i<chapterList.length;i++){%>
            <div class="oneblog">
                <h2><a title="路·过-喜欢在路上" href="/"><%= chapterList[i]['chapterName'] %></a></h2>
                <figure><img src='<%= chapterList[i]['imgPath'] %>' border='0' width='120' height='120' alt='路·过-喜欢在路上'>
                </figure>
                <ul class="nlist">
                    <p><%= chapterList[i]['chapterDes'].slice(0,100)+'...'%> </p>
                    <a title="路·过-喜欢在路上" href='/detail/<%= chapterList[i]['id'] %>' target="_blank" class="readmore">阅读全文>></a>
                </ul>
                <p class="dateview">
                    <span>发布时间：<%= chapterList[i]['publishTimer']%></span>
                    <span>作者：<%= chapterList[i]['author']%></span>
                    <span>分类：[<a href="/">悠客</a>]</span>
                    <span class="nl">浏览（<%= chapterList[i]['views']%>)</span>
                    <span class="n2">评论（<a href="/">0</a>）</span>
                <div class="line"></div>
                </p>
            </div>
          <% } %> 
            <div id="result"></div>


            <!--分页开始-->
            <div class="page">

            </div>
            <!--分页结束-->
        </div>
    </article>
    <footer>
        <p class="ft-copyright">个人博客 Sunshine </p>
        <div id="tbox"> <a id="togbook" href=""></a> <a id="gotop" href="javascript:void(0)"></a></div>
    </footer>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<script>
    $.get("http://localhost:8084/getChapterList", function (data) {
        var data = {
            "title": '欢迎使用baiduTemplate',
            "list": JSON.parse(data)
        };
        var bt = baidu.template;
        var html = bt('t:_1234-abcd-1', data);
        document.getElementById('result').innerHTML = html;
        console.log(data);
    })

    function showDetail(e, chapterId) {
        e.preventDefault();
        console.log(chapterId);
        window.location = "http://localhost:8083/detail?chapterId=" + chapterId;
    }
</script>

</html>